package plugin;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

public class AlignBox extends JPanel {
	private static final long serialVersionUID = 1L;

	protected AlignBox(String text) {
    	this(new JLabel(text));
    }

	protected AlignBox(JComponent input) {
		this(input, SwingConstants.CENTER, false);
	}

	protected AlignBox(JComponent input, boolean opaque) {
		this(input, SwingConstants.CENTER, false);
	}

	protected AlignBox(JComponent input, int alignment, boolean opaque) {
		this.setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
		if (alignment == SwingConstants.CENTER
				|| alignment == SwingConstants.RIGHT)
			this.add(Box.createHorizontalGlue());
		this.add(input);
		if (alignment == SwingConstants.CENTER
				|| alignment == SwingConstants.LEFT)
			this.add(Box.createHorizontalGlue());
		this.setOpaque(opaque);

	}

}
